package com.example.duanjunjie.learn.json;

import com.google.gson.stream.JsonReader;

import java.io.IOException;

/**
 * Created by duanjunjie on 2018/3/20.
 */

public class DataItem {
    public String click_trace;
    public Classification classification;
    public Decoder decoder;
    public Definition_option definition_option;
    public String display_type;
    public String hardware;
    public String hostid;
    public String id;
    public String name;
    public String person_num;
    public String room_type;
    public String start_time;
    public String status;
    public String style_type;
    public String tx_stat;
    public String xy_stat;
    public Userinfo userinfo;
    public Pictures pictures;

    public DataItem() {
        this.classification = new Classification();
        this.decoder = new Decoder();
        this.definition_option = new Definition_option();
        this.userinfo = new Userinfo();
        this.pictures = new Pictures();
    }

    public class Userinfo {
        public String avatar;
        public String nickName;
        public String rid;
        public String userName;

        public void read(JsonReader reader) throws IOException {
            reader.beginObject();
            while (reader.hasNext()) {
                String nextName = reader.nextName();
                switch (nextName) {
                    case "avatar":
                        avatar = reader.nextString();
                        break;
                    case "nickName":
                        nickName = reader.nextString();
                        break;
                    case "rid":
                        rid = reader.nextString();
                        break;
                    case "userName":
                        userName = reader.nextString();
                        break;
                    default:
                        reader.skipValue();
                        break;
                }
            }
            reader.endObject();
        }
    }

    public class Pictures {
        public String img;

        public void read(JsonReader reader) throws IOException {
            reader.beginObject();
            while (reader.hasNext()) {
                String nextName = reader.nextName();
                switch (nextName) {
                    case "img":
                        img = reader.nextString();
                        break;
                    default:
                        reader.skipValue();
                        break;
                }
            }
            reader.endObject();
        }
    }

    public class Classification {
        public String cname;
        public String ename;

        public void read(JsonReader reader) throws IOException {
            reader.beginObject();
            while (reader.hasNext()) {
                String nextName = reader.nextName();
                switch (nextName) {
                    case "cname":
                        cname = reader.nextString();
                        break;
                    case "ename":
                        ename = reader.nextString();
                        break;
                    default:
                        reader.skipValue();
                        break;
                }
            }
            reader.endObject();
        }
    }

    public class Decoder {
        public String HD;
        public String OD;
        public String SD;

        public void read(JsonReader reader) throws IOException {
            reader.beginObject();
            while (reader.hasNext()) {
                String nextName = reader.nextName();
                switch (nextName) {
                    case "HD":
                        HD = reader.nextString();
                        break;
                    case "OD":
                        OD = reader.nextString();
                        break;
                    case "SD":
                        SD = reader.nextString();
                        break;
                    default:
                        reader.skipValue();
                        break;
                }
            }
            reader.endObject();
        }
    }

    public class Definition_option {
        public String HD;
        public String OD;
        public String SD;

        public void read(JsonReader reader) throws IOException {
            reader.beginObject();
            while (reader.hasNext()) {
                String nextName = reader.nextName();
                switch (nextName) {
                    case "HD":
                        HD = reader.nextString();
                        break;
                    case "OD":
                        OD = reader.nextString();
                        break;
                    case "SD":
                        SD = reader.nextString();
                        break;
                    default:
                        reader.skipValue();
                        break;
                }
            }
            reader.endObject();
        }
    }

    public void read(JsonReader reader) throws Exception {
        reader.beginObject();
        while (reader.hasNext()) {
            String nextName = reader.nextName();
            switch (nextName) {
                case "classification":
                    classification.read(reader);
                    break;
                case "userinfo":
                    userinfo.read(reader);
                    break;
                case "pictures":
                    pictures.read(reader);
                    break;
                case "decoder":
                    decoder.read(reader);
                    break;
                case "definition_option":
                    definition_option.read(reader);
                    break;
                case "click_trace":
                    click_trace = reader.nextString();
                    break;
                case "display_type":
                    display_type = reader.nextString();
                    break;
                case "hardware":
                    hardware = reader.nextString();
                    break;
                case "hostid":
                    hostid = reader.nextString();
                    break;
                case "person_num":
                    person_num = reader.nextString();
                    break;
                case "room_type":
                    room_type = reader.nextString();
                    break;
                case "start_time":
                    start_time = reader.nextString();
                    break;
                case "status":
                    status = reader.nextString();
                    break;
                case "style_type":
                    style_type = reader.nextString();
                    break;
                case "tx_stat":
                    tx_stat = reader.nextString();
                    break;
                case "xy_stat":
                    xy_stat = reader.nextString();
                    break;
                default:
                    reader.skipValue();
                    break;
            }
        }
        reader.endObject();
    }
}
